﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Mimoza.AgentLayer.Communication;
using Mimoza.Transport;

namespace Mimoza.ServiceLayer
{
    class ServiceTimeSynchronizer : BaseObject
    {
        public ServiceTimeSynchronizer(Configuration config)
            : base(config)
        {
            RequestTimeSynch.RegisterHandler(
                new RequestTimeSynch.Handler(ProcessRequestTimeSynch));
            ReplyTimeSynch.RegisterInTransport();
        }

        ReplyTimeSynch ProcessRequestTimeSynch(RequestTimeSynch request)
        {
            Common.Logger.Log.Info("ServiceTimeSynchronizer.ProcessRequestTimeSynch hostId - '"
                + request.HostId.ToString() + "' .");

            ReplyTimeSynch reply = new ReplyTimeSynch();
            reply.HostIdTo = request.HostId;
            reply.ServiceDateTime = DateTime.Now.ToUniversalTime();

            return reply;
        }
    }
}
